package com.suray.wcs.service.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.suray.basic.wcs.utils.IBaseEnum;

import java.io.Serializable;

public enum PrecessOperation implements IBaseEnum<Serializable> {
    INTERRUPT(1, "中断"),
    RECOVER(2, "恢复"),
    UPDATE_N(3, "更新无货"),
    UPDATE_Y(4, "更新有货"),
    INIT(5,"初始化"),
    UNLOCK(6,"解锁"),
    COMMIT_WMS(7,"提交WMS")
    ;

    @EnumValue
    private int precessOperation;
    @JsonValue
    private String description;

    PrecessOperation(int precessOperation, String description) {
        this.precessOperation = precessOperation;
        this.description = description;
    }

    @Override
    public String toString() {
        return description;
    }

    public static PrecessOperation parsePrecess(int precessStatus) {
        PrecessOperation[] precessStatuses = PrecessOperation.values();
        for (PrecessOperation type : precessStatuses) {
            if (type.precessOperation == precessStatus) {
                return type;
            }
        }
        throw new IllegalArgumentException("进度参数错误:" + precessStatus);
    }

    public static PrecessOperation getByPrecess(int precessStatus) {
        PrecessOperation[] precessStatuses = PrecessOperation.values();
        for (PrecessOperation type : precessStatuses) {
            if (type.precessOperation == precessStatus) {
                return type;
            }
        }
        return null;
    }

    public static PrecessOperation parsePrecess(String description) {
        PrecessOperation[] taskTypes = PrecessOperation.values();
        for (PrecessOperation type : taskTypes) {
            if (type.description.equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("进度描述错误:" + description);
    }

    public int getTypeNum() {

        return precessOperation;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public Integer getValue() {
        return precessOperation;
    }

    @Override
    public Integer getVal() {
        // TODO Auto-generated method stub
        return null;
    }


}
